* Arexx script for FrexxEd as replacement for Ed used with Ced
* Also used by "freds" and "bin/startfred".
*
* Orginally by Daniel Stenberg & Michiel Willems.
* Altered by Nicolas Dade (nicolas-dade@uiuc.edu) to be more general.
* Altered by Mogens Isager to be even more general :-).
* Altered by Nicolas Dade again to fold Mogens' changes into my private version.
* Altered by Mathias Axelsson to add some command line options
*
* NEW FEATURES:
* (5.2.95) [Nicolas]
* o correctly handles relative paths in Filename.
* o handles multiple filenames.
* o cleaned up STICKY code.
* (18.2.95) [Nicolas]
* o STICKY can appear anywhere in the arguments.
* (20.2.95) [Daniel/Kjell]
* o Added the iconfy-stuff!
* (23.2.95) [Nicolas]
* o it's ok to open more than one new file at once.
* o starting with no arguments makes Fred pop up a requester.
* o eliminated NOARGS code because NOARGS was never used.
* o moved "run Fred" out of loop.
* o moved "Deiconify(); WindowToFront();" out of loop.
* (4.6.95) [Mogens]
* o Made some changes to handle no args or just STICKY.
* (6.6.95) [Nicolas]
* o folded some of Mogen's changes into my code
* o changed fpl/KillNotify.FPL to be smarter about multiple files and re-iconifying.
* This meant adding the global info _iconify_when_quit_countdown that counts the total number of buffers that were opened while iconified.
* o ARexxRead()s replaced by having arexx place the variable directly in the FPL code.
* o In order to keep the user from deiconifying while we open the files, the command(s) to FrexxEd are built up in arexx, and then sent as one long command.
*
* (8.11.95) [Mathias]
* o Added some more command line options:
* x Left=<#> Sets left edge of window
* x Top=<#> Sets top edge of window
* x Width=<#> Sets width of window
* x Height=<#> Sets height of window
* x Window=<#> Sets type of the window. See Functions.guide/ReadInfo()
IF UPPER(Name.NumArgs) = "STICKY" & ~Sticky THEN DO /* if sticky appears twice then the second time it refers to a file */
Sticky = 1
NumArgs = NumArgs - 1 /* sticky will not be counted in NumArgs */
END
IF UPPER(Left(Name.NumArgs,4)) = "LEFT" & ~Left THEN DO
Left = 1
parse var Name.NumArgs'='LeftEdge
NumArgs = NumArgs - 1
END
IF UPPER(Left(Name.NumArgs,3)) = "TOP" & ~Top THEN DO
Top = 1
parse var Name.NumArgs'='TopEdge
NumArgs = NumArgs - 1
END
IF UPPER(Left(Name.NumArgs,5)) = "WIDTH" & ~Width THEN DO
Width = 1
parse var Name.NumArgs'='WidthSize
NumArgs = NumArgs - 1
END
IF UPPER(Left(Name.NumArgs,6)) = "HEIGHT" & ~Height THEN DO
Height = 1
parse var Name.NumArgs'='HeightSize
NumArgs = NumArgs - 1
END
IF UPPER(Left(Name.NumArgs,6)) = "WINDOW" & ~Window THEN DO
Window = 1
parse var Name.NumArgs'='WindowType
NumArgs = NumArgs - 1
END
IF UPPER(Left(Name.NumArgs,6)) = "SCREEN" & ~Screen THEN DO
Screen = 1
parse var Name.NumArgs'='ScreenName
NumArgs = NumArgs - 1
END
END
/* if Sticky then setup a port for us to use */
OurPort="ED_FREXXED.no port"
IF Sticky THEN DO
i = 1
cont = 0
DO while i<100 /* no more than 100 simultaneous startups! */
IF ~SHOW("P", "ED_FREXXED."i) THEN DO
OurPort = "ED_FREXXED."i
cont = OPENPORT(OurPort)
IF cont THEN i = 100 /* we might not get the port if someone else creates it between the SHOW() and the OPENPORT() */
END
i = i + 1
END
IF ~cont THEN DO
SAY "We found no free port to use!"
EXIT(5)
END
END
/* Because of problems with the user tweaking the window while the files are being opened, I accumulate all the fpl code in FPLCode and then execute it all at once at the end */
FPLCode = 'int ID, oldID;'
/* if files where specified, load each file into FrexxEd */
IF NumArgs > 0 THEN DO
/* make sure KillNotify.FPL has been loaded, and add our NumArgs to the iconify countdown */